<template>
  <VanActionSheet
    v-model:show="showPopup"
    teleport="body"
    @closed="emit('closed')"
    class="question-list-popup"
    style="height: 50%"
  >
    <div class="content">
      <div
        v-for="item in list"
        :key="item.id"
        @click="!item.disabled && emit('handleItem', item)"
        class="question-item"
        :class="{ disabled: item.disabled }"
      >
        <span class="question-item-title">{{ item.desc }}</span>
        <img src="@/assets/images/wrongBook/icon-arrow-right-gray.png" />
      </div>
      <div class="btn">
        <VanButton
          size="small"
          color="linear-gradient( 270deg, #29F19C 0%, #02A1F9 100%)"
        >
          完成
        </VanButton>
      </div>
    </div>
  </VanActionSheet>
</template>
<script setup>
import { defineProps, reactive, toRefs, watch, defineEmits } from "vue";

import { ActionSheet as VanActionSheet, Button as VanButton } from "vant";

const props = defineProps({
  show: {
    type: Boolean,
    default: false,
  },
  list: {
    type: Array,
    default: () => [],
  },
});
const emit = defineEmits(["closed", "handleItem"]);
const state = reactive({
  showPopup: false,
});
watch(
  () => props.show,
  (newVal) => {
    state.showPopup = newVal;
  }
);

const { showPopup } = toRefs(state);
</script>
<style scoped lang="scss">
.question-list-popup {
  font-family: PingFangSC, PingFang SC;
  .content {
    padding: 20px 10px 75px;
    .question-item {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 16px 0;
      border-bottom: 1px solid #e5e5e5;
      &-title {
        color: #333;
        font-size: 16px;
      }
      img {
        width: 7px;
      }
    }
    .btn {
      background-color: #fff;
      padding: 10px;
      box-sizing: border-box;
      width: 100%;
      position: fixed;
      bottom: 0;
      left: 0;
      box-shadow: 0px -2px 8px 0px rgba(24, 24, 24, 0.08);
      .van-button {
        height: 45px;
        width: 100%;
        border-radius: 20px;
        font-size: 18px;
        font-weight: 500;
      }
    }
  }
}
</style>
